<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/4/2 0002
 * Time: 9:02
 */
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Supply extends CI_Controller {

    function __construct(){
        parent::__construct();
    }

    public function index(){
        $vdata['active'] = "supply";
        $vdata['title'] = "供应链金融" . ' - ' . CON_KEYWORDS;
        $this->load->view('supply/index',$vdata);
    }

    public function apply(){
        $vdata['active'] = "supply";
        $vdata['title'] = "申请" . ' - ' . CON_KEYWORDS;
        $this->load->view('supply/apply',$vdata);
    }

    public function apply_post(){
//        var_dump($_POST);
//        var_dump($_SESSION);exit;
        $data=$_POST;
        $user=$this->session->userdata('zjy_user');
        $data['user_id']=$user['user_id'];
        $data['apply_time']=time();
//        var_dump($data);exit;
        if($data['company_name']==''||$data['company_organization_code']==''||$data['company_address']==''||$data['connect_name']==''||$data['connect_tel']==''||$data['apply_amount']==''){
            echo "<script>alert('请填写完整再提交！');history.back(-1);</script>";exit;
        }
        $this->load->model('Supply_model','supply');
        if(!$this->supply->add($data)){
            echo "<script>alert('提交失败');history.go(-1);</script>";
        } else {
            echo "<script>alert('提交成功！请等待审核。');window.location.href='/supply/index';</script>";
        }
    }
}